package Testclass.ajaxTest;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/ajax2")
public class ajax2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      req.setCharacterEncoding("utf-8");
       resp.setContentType("text/html;charset=utf-8");

        String name = req.getParameter("name");
        String key = req.getParameter("key");

        PrintWriter writer = resp.getWriter();
        writer.write("后端用户"+name);
        writer.write("后端密码"+key);
    }
}
